var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

/* GET home page. */
router.get('/getData', function (req , res) {
  console.log('yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy')
  res.send({
    nodes: [
              { data: { id: 'n0' ,type:'router', label:'[p0 , p1]' } },
              { data: { id: 'n1' ,type:'server' , label:'[p0 , p1]'} },
              { data: { id: 'n2' ,type:'switch' , label:'[p0 , p1]'} },
              { data: { id: 'n3' ,type:'el' , label:'[p0 , p1]'} },
              { data: { id: 'n4' ,type:'switch' , label:'[p0 , p1]'} },
              { data: { id: 'n5' ,type:'server' , label:'[p0 , p1]'} },
              { data: { id: 'n6' ,type:'icnd' , label:'[p0 , p1]'} },
              { data: { id: 'n7' ,type:'icnd' , label:'[p0 , p1]'} },
              { data: { id: 'n8' ,type:'safety' , label:'[p0 , p1]'} },
              { data: { id: 'n9' ,type:'safety' , label:'[p0 , p1]'} },
              { data: { id: 'n10' ,type:'server' , label:'[p0 , p1]'} },
              { data: { id: 'n11' ,type:'storage' , label:'[p0 , p1]'} },
              { data: { id: 'n12' ,type:'storage' , label:'[p0 , p1]'} },
              { data: { id: 'n13' ,type:'safety' , label:'[p0 , p1]'} },
              { data: { id: 'n14' ,type:'storage' , label:'[p0 , p1]'} },
              { data: { id: 'n15' ,type:'switch' , label:'[p0 , p1]'} },
              { data: { id: 'n16' ,type:'switch' , label:'[p0 , p1]'} }
            ],
            edges: [
              { data: { source: 'n0', target: 'n1' ,bg:'', sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n1', target: 'n2' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n1', target: 'n3' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n4', target: 'n5' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n4', target: 'n6' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n6', target: 'n7' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n6', target: 'n8' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n8', target: 'n9' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n8', target: 'n10' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n11', target: 'n12' , sLabel:'n11', tLabel:'n22'} },
              { data: { source: 'n12', target: 'n13' } },
              { data: { source: 'n13', target: 'n14' } },
              { data: { source: 'n13', target: 'n15' } },
              { data: { source: 'n11', target: 'n15' } }
            ]
  })
})


router.get('/shortPath', function (req , res) {
  res.send([{ data: { source: 'n0', target: 'n1' , label:'[p0 , p1]'} },
              { data: { source: 'n1', target: 'n2' , label:'[p2 , p3]'} }])
})

module.exports = router;
